package cn.edu.njust.epms.common.ExceptionHandler;

import cn.edu.njust.epms.common.Resp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;



/**
 * 全局异常处理类
 */
@ControllerAdvice(annotations = {RestController.class, Controller.class})
@ResponseBody
@Order(10000)
@Slf4j
public class GlobalExceptionHandler2 {

    /**
     * 异常处理方法
     * @return
     */
    @ExceptionHandler(Exception.class)
    public Resp<String> exceptionHandler(Exception e) {
        return Resp.error("未知错误:"+e.getMessage());
    }
}
